package battleship.view;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;


@SuppressWarnings("serial")
public class ResizingField extends JPanel{

	int x = 10;
	int y = 10;
	
	public ResizingField()
	{
		
	}
	
	public void paintGrid(int height, int width)
	{
		this.y = height;
		this.x = width;
		repaint();
	}
	
	
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);

		Graphics2D g2 = (Graphics2D) g;
		GradientPaint gp = new GradientPaint(0.0f, 0.0f, new Color(40,200,180),
				   250.0f, 250.0f, new Color(40,100,210));
		
		g2.setPaint(gp);
		
		g2.fillRect(0, 0, x * 25, y * 25);

		g2.setColor(Color.black);
		
		for (int i=1; i<x; i++)
		{
			g2.drawLine(i*25,0,i*25,y * 25);
		}
		for (int i=1; i<y; i++)
		{
			g2.drawLine(0,i*25,x * 25,i*25);
		}

		g2.draw3DRect(0,0,x * 25,y * 25,false);
	}
}
